﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Kinect;

namespace TSL
{
    /// <summary>
    /// Interaction logic for AdjustAngle.xaml
    /// </summary>
    public partial class AdjustAngle : Window
    {
        public AdjustAngle()
        {
            InitializeComponent();
        }

        KinectSensor _sensor;

        public AdjustAngle(KinectSensor k)
        {
            InitializeComponent();
            _sensor = k;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            button1.IsEnabled = false;

            //Set angle to slider1 value
            if (_sensor != null && _sensor.IsRunning)
            {
                _sensor.ElevationAngle = (int)slider1.Value;
                lblCurrentAngle.Content = _sensor.ElevationAngle;
            }

            //Do not change Elevation Angle often, please see documentation on this and Kinect Explorer for a robust example
            System.Threading.Thread.Sleep(new TimeSpan(hours: 0, minutes: 0, seconds: 1));
            button1.IsEnabled = true; 
        }
    }
}
